import { Card, Table, Button } from 'antd';

// 生成随机虚拟数据的函数
const generateRandomData = (count: number) => {
  const statuses = ['待付款', '已付款', '已发货', '已完成'];
  const data = [];
  for (let i = 0; i < count; i++) {
    data.push({
      id: i + 1,
      order_id: i + 1,
      customer_id: Math.floor(Math.random() * 10) + 1,
      salesperson_id: Math.floor(Math.random() * 10) + 1,
      order_date: new Date(Date.now() - Math.random() * 30 * 24 * 60 * 60 * 1000).toLocaleDateString(),
      delivery_date: new Date(Date.now() + Math.random() * 30 * 24 * 60 * 60 * 1000).toLocaleDateString(),
      order_status: statuses[Math.floor(Math.random() * statuses.length)],
      total_amount: (Math.random() * 1000).toFixed(2),
    });
  }
  return data;
};

const randomData = generateRandomData(10);

export default function SalesOrder() {
  const columns = [
    {
      title: '销售订单 ID',
      dataIndex: 'order_id',
    },
    {
      title: '客户 ID',
      dataIndex: 'customer_id',
    },
    {
      title: '销售人员 ID',
      dataIndex: 'salesperson_id',
    },
    {
      title: '订单日期',
      dataIndex: 'order_date',
    },
    {
      title: '交货日期',
      dataIndex: 'delivery_date',
    },
    {
      title: '订单状态',
      dataIndex: 'order_status',
    },
    {
      title: '总金额',
      dataIndex: 'total_amount',
    },
    {
      title: '操作',
      render: () => (
        <Button type="link">详情</Button>
      ),
    },
  ];

  return (
    <div style={{ padding: 24 }}>
        <Button type="primary" style={{ marginBottom: 16 }}>新建订单</Button>
        <Table columns={columns} dataSource={randomData} rowKey="id" size='small' />

    </div>
  );
}